<h:panelGrid xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:t="http://myfaces.apache.org/tomahawk" width="100%"
	id="attachementPanelGrid">
	<t:saveState value="#{evokPatientAttachementBean.domainPatient}" />
	<t:saveState value="#{evokPatientAttachementBean.patientAtt}" />
	<h:inputHidden value="#{evokPatientAttachementBean.domainPatient.id}" />

	<h:panelGrid width="100%" id="pnlUploadInfo">
		<h:inputHidden value="#{evokPatientTherapyBean.att.id}" />
		<p:panelGrid style="width:100%" columns="2"
			columnClasses="width30,width70">
			<h:outputLabel value="#{msgs.msg_headline} *" />
			<p:inputTextarea style="width:95%;" value="#{evokPatientAttachementBean.patientAtt.description}"
				maxlength="255" rows="3"  />

			<h:outputLabel value="#{msgs.default_upload}" />
			<h:panelGroup>
				<t:inputFileUpload accept="docs/*" size="50"
					value="#{evokPatientAttachementBean.uploadAtt}" storage="file"
					styleClass="fileUploadInput" maxlength="100000" />
			</h:panelGroup>
		</p:panelGrid>
	</h:panelGrid>

	<h:panelGrid style="float:right;" columns="2">
		<p:commandButton action="#{evokPatientAttachementBean.submitAction}"
			ajax="false" icon="ui-icon-disk" value="#{msgs.button_submit}" 
			update="patientAttlist"/>

		<p:commandButton actionListener="#{evokPatientTherapyBean.resetAction}"
			icon="ui-icon-arrowrefresh-1-n" value="#{msgs.button_reset}"
			update="pnlUploadInfo" />
	</h:panelGrid>

	<p:dataTable var="pa" id="patientAttlist" rowIndexVar="ri"
		emptyMessage="" value="#{evokPatientAttachementBean.patientAttModel}" selectionMode="single"
		widgetVar="wdgPatientAttList" rowKey="#{pa.id}">
		
		<p:ajax event="rowSelect"
			update=":mainform:paitentInfo:pnlUploadInfo"
			listener="#{evokPatientAttachementBean.selectAtt}" />
		
		<p:column styleClass="width5">
			<f:facet name="header">
				<h:outputText value="#{msgs.table_index}" />
			</f:facet>
			<h:outputText value="#{ri+1}" />
		</p:column>

		<p:column headerText="#{msgs.default_create_time}">
			<h:outputText value="#{pa.createTime}">
				<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
			</h:outputText>
		</p:column>

		<p:column headerText="#{msgs.msg_headline}" styleClass="width30">
			<h:outputText value="#{pa.description}" />
		</p:column>

		<p:column headerText="#{msgs.default_attachment}" styleClass="width20">
			<h:outputLink target="_blank" value="#{pa.filePath}"
				styleClass="button" rendered="#{pa.filePath!=null}">
				<h:outputText value="#{pa.fileName}" />
			</h:outputLink>
		</p:column>

		<p:column styleClass="width5">
			<f:facet name="header">
				<t:outputText value="#{msgs.table_column_operation}" />
			</f:facet>
			<h:panelGrid columns="2" styleClass="gridNoBorder">
				<p:commandLink oncomplete="confirmAttachementDelete.show()"
					styleClass="ui-icon ui-icon-trash" title="#{msgs.button_delete}"
					type="image" immediate="true">
					<f:setPropertyActionListener value="#{pa}"
						target="#{evokPatientAttachementBean.patientAtt}" />
				</p:commandLink>
			</h:panelGrid>
		</p:column>
	</p:dataTable>
</h:panelGrid>
